﻿using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Linq;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;

namespace IdentityNotes.Examples.CustomActivityLibrary
{
    public partial class SendAccountErrorToSSActivity : SequenceActivity
    {
        public SendAccountErrorToSSActivity()
        {
            InitializeComponent();
        }

        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        [Category("Properties")]
        [FIMActivityUI(ControlType.String, 24, 2)]
        public string ErrorMessage
        {
            get { return (string)this.GetValue(SendAccountErrorToSSActivity.ErrorMessageProperty); }
            set { this.SetValue(SendAccountErrorToSSActivity.ErrorMessageProperty, value); }
        }

        public static DependencyProperty ErrorMessageProperty = DependencyProperty.Register("ErrorMessage", typeof(string), typeof(SendAccountErrorToSSActivity));

        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        [Category("Properties")]
        [FIMActivityUIAttribute(ControlType.String, 15, 1)]
        public string NumberToUse
        {
            get { return (string)this.GetValue(SendAccountErrorToSSActivity.NumberToUseProperty); }
            set { this.SetValue(SendAccountErrorToSSActivity.NumberToUseProperty, value); }
        }

        public static DependencyProperty NumberToUseProperty = DependencyProperty.Register("NumberToUse", typeof(string), typeof(SendAccountErrorToSSActivity));

        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        [Category("Properties")]
        [FIMActivityUIAttribute(ControlType.String, 15, 1)]
        public string Queue
        {
            get { return (string)this.GetValue(SendAccountErrorToSSActivity.QueueProperty); }
            set { this.SetValue(SendAccountErrorToSSActivity.QueueProperty, value); }
        }

        public static DependencyProperty QueueProperty = DependencyProperty.Register("Queue", typeof(string), typeof(SendAccountErrorToSSActivity));


        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        [Category("Properties")]
        [FIMActivityUIAttribute(ControlType.String, 15, 1)]
        public string CallingNumber
        {
            get { return (string)this.GetValue(SendAccountErrorToSSActivity.CallingNumberProperty); }
            set { this.SetValue(SendAccountErrorToSSActivity.CallingNumberProperty, value); }
        }

        public static DependencyProperty CallingNumberProperty = DependencyProperty.Register("CallingNumber", typeof(string), typeof(SendAccountErrorToSSActivity));






        public static DependencyProperty targetResourceProperty = DependencyProperty.Register("targetResource", typeof(Microsoft.ResourceManagement.WebServices.WSResourceManagement.ResourceType), typeof(IdentityNotes.Examples.CustomActivityLibrary.SendAccountErrorToSSActivity));

        [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
        [BrowsableAttribute(true)]
        [CategoryAttribute("Parameters")]
        public Microsoft.ResourceManagement.WebServices.WSResourceManagement.ResourceType targetResource
        {
            get
            {
                return ((Microsoft.ResourceManagement.WebServices.WSResourceManagement.ResourceType)(base.GetValue(IdentityNotes.Examples.CustomActivityLibrary.SendAccountErrorToSSActivity.targetResourceProperty)));
            }
            set
            {
                base.SetValue(IdentityNotes.Examples.CustomActivityLibrary.SendAccountErrorToSSActivity.targetResourceProperty, value);
            }
        }

        private void generateSSMessage_ExecuteCode(object sender, EventArgs e)
        {
            string sendToNumber = targetResource[this.NumberToUse] as string;
            sendToNumber.Replace("-", "");

            this.sendSpeechServerMessageActivity1.Message = 
                string.Format("OutboundPhoneNumber={0}&CallingParty={1}&Name={2}&Problem={3}&ResourceGUID={4}",
                sendToNumber,
                CallingNumber,
                targetResource["FirstName"] as string,
                this.ErrorMessage,
                targetResource.ObjectID.ToString());
        }

    }
}
